package com.miyake.dsp.osa;

import java.util.ArrayList;
import java.util.List;

import com.miyake.dsp.osa.lab.LabUiAnnotation;

public class OsaSetting {
	public VBW getVbw() {
		return vbw;
	}

	public void setVbw(VBW vbw) {
		this.vbw = vbw;
	}

	private double startWavelength = 1500;
	private double stopWavelength = 1600;
	@LabUiAnnotation(caption="Center Wavelength")
	private double centerWavelength = 1550;
	@LabUiAnnotation(caption="Span Wavelength")
	private double spanWavelength = 100;
	private double actualResolution;
	private double settingResolution;
	@LabUiAnnotation(caption="Sampling Point")
	private int samplingPoints = 501;
	@LabUiAnnotation(caption="VBW")
	private VBW vbw = VBW._1kHz;
	private boolean air;
	
	
	public enum VBW {
		_1MHz, _100kHz, _10kHz, _2kHz, _1kHz, _200Hz, _100Hz, _10Hz
	};
	
	public boolean isAir() {
		return air;
	}

	public void setAir(boolean air) {
		this.air = air;
	}

	private List<double[]> trace = new ArrayList<double[]>();
	
	public OsaSetting() {
		this.setStartWavelength(1500.0);
		this.setStopWavelength(1600.0);
		this.setActualResolution(1);
		this.setSamplingPoints(501);
	}
	
	public int getSamplingPoints() {
		return samplingPoints;
	}

	public void setSamplingPoints(int samplingPoints) {
		this.samplingPoints = samplingPoints;
	}

	public double getStartWavelength() {
		return startWavelength;
	}
	public void setStartWavelength(double startWavelength) {
		this.startWavelength = startWavelength;
		calcCenterSpan();
	}
	public double getStopWavelength() {
		return stopWavelength;
	}
	
	public void setStopWavelength(double stopWavelength) {
		this.stopWavelength = stopWavelength;
		calcCenterSpan();
	}
	public double getCenterWavelength() {
		return centerWavelength;
	}
	public void setCenterWavelength(double centerWavelength) {
		this.centerWavelength = centerWavelength;
		calcStartStop();
	}

	public double getSpanWavelength() {
		return spanWavelength;
	}
	public void setSpanWavelength(double spanWavelength) {
		this.spanWavelength = spanWavelength;
		calcStartStop();
	}
	public double getActualResolution() {
		return actualResolution;
	}
	public void setActualResolution(double actualResolution) {
		this.actualResolution = actualResolution;
	}
	
	private void calcCenterSpan() {
		this.centerWavelength = (this.startWavelength + this.stopWavelength) / 2.0;
		this.spanWavelength = (this.stopWavelength - this.startWavelength);
	}
	
	private void calcStartStop() {
		this.startWavelength = this.centerWavelength - this.spanWavelength / 2.0;
		this.stopWavelength = this.centerWavelength + this.spanWavelength / 2.0;		
	}

	public double getSettingResolution() {
		return settingResolution;
	}

	public void setSettingResolution(double settingResolution) {
		this.settingResolution = settingResolution;
	}
	
	public double getSamplingResolution() {
		return this.spanWavelength / (this.samplingPoints-1);
	}
}
